#include<bits/stdc++.h>
#define int long long
#define N 1000006
using namespace std;

int n, q, ans, S;
string s;
int Pre[N], Suf[N];
int D[N];
signed main() {
	freopen("good.in", "r", stdin);
	freopen("good.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> q;
	cin >> s; s = " " + s;
	
	int num = 0;
	while(q--) {
		num++;
		//if(num % 1000 == 0) cerr << "e";
		int l, r;
		ans = 0;
		cin >> l >> r;
		Pre[l - 1] = Suf[r + 1] = 0;
		for(int i = l; i <= r; i++) {
			D[i] = 0;
			Pre[i] = Pre[i - 1];
			if(s[i] == '0') Pre[i]--;
			else Pre[i]++;
		}
		for(int i = r; i >= l; i--) {
			Suf[i] = Suf[i + 1];
			if(s[i] == '0') Suf[i]--;
			else Suf[i]++;
		}
		
		int sum = 0;
		for(int i = r; i >= l; i--) {
			Suf[i] += sum;
			if(Suf[i] < 0) {
				D[i] += (-Suf[i]);
				sum += (-Suf[i]); 
				Suf[i] = 0;
			}
		}
		ans = sum;
		for(int i = r; i >= l; i--) {
			sum -= D[i];
			Pre[i] += sum;
			
		}
		sum = 0;
		for(int i = l; i <= r; i++) {
			Pre[i] += sum;
			if(Pre[i] < 0) sum += (-Pre[i]);
		}
		ans += sum;
		//cout << ans << endl;
		S ^= ans;
	}
	cout << S;
	return 0;
}

/*
10 5
0001001111
1 10
4 6
4 7
5 7
1 6
*/

